package fr.afcepf.atod16.groupe1.projet1.entities.administration;

import fr.afcepf.atod16.groupe1.projet1.entities.Entite;
import fr.afcepf.atod16.groupe1.projet1.enumerations.Role;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * L'entité compte cemploye
 * @author cedric
 */
@Entity
@Table(name = "comptes_employes")
public class CompteEmploye implements Serializable, Entite {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name="id")
    private Integer id;
    @Column(name="login", nullable = false, length = 32)
    private String login;
    @Column(name="pass", nullable = false, length = 32)
    private String pass;
    @Column(name="civilite", nullable = false, length = 16)
    private String civilite;
    @Column(name="nom", nullable = false, length = 100)
    private String nom;
    @Column(name="prenom", nullable = false, length = 100)
    private String prenom;
    @Column(name="email", nullable = false)
    private String email;
    @Enumerated(EnumType.STRING)
    @Column(name="role_employe", nullable = false, length = 15)
    private Role roleEmploye;

    public CompteEmploye() {
    }

    public CompteEmploye(Integer id, String login, String pass, String civilite,
            String nom, String prenom, String email, Role role) {
        this.id = id;
        this.login = login;
        this.pass = pass;
        this.civilite = civilite;
        this.nom = nom;
        this.prenom = prenom;
        this.email = email;
        this.roleEmploye = role;
    }

    @Override
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public String getCivilite() {
        return civilite;
    }

    public void setCivilite(String civilite) {
        this.civilite = civilite;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Role getRoleEmploye() {
        return roleEmploye;
    }

    public void setRoleEmploye(Role roleEmploye) {
        this.roleEmploye = roleEmploye;
    }

    @Override
    public String toString() {
        return "CompteEmploye [id=" + id + ", login=" + login + ", pass="
                + pass + ", civilite=" + civilite + ", nom=" + nom
                + ", prenom=" + prenom + ", email=" + email + ", role=" + roleEmploye
                + "]";
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result
                + ((civilite == null) ? 0 : civilite.hashCode());
        result = prime * result + ((email == null) ? 0 : email.hashCode());
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((login == null) ? 0 : login.hashCode());
        result = prime * result + ((nom == null) ? 0 : nom.hashCode());
        result = prime * result + ((pass == null) ? 0 : pass.hashCode());
        result = prime * result + ((prenom == null) ? 0 : prenom.hashCode());
        result = prime * result + ((roleEmploye == null) ? 0 : roleEmploye.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        CompteEmploye other = (CompteEmploye) obj;
        if (civilite == null) {
            if (other.civilite != null) {
                return false;
            }
        } else if (!civilite.equals(other.civilite)) {
            return false;
        }
        if (email == null) {
            if (other.email != null) {
                return false;
            }
        } else if (!email.equals(other.email)) {
            return false;
        }
        if (id == null) {
            if (other.id != null) {
                return false;
            }
        } else if (!id.equals(other.id)) {
            return false;
        }
        if (login == null) {
            if (other.login != null) {
                return false;
            }
        } else if (!login.equals(other.login)) {
            return false;
        }
        if (nom == null) {
            if (other.nom != null) {
                return false;
            }
        } else if (!nom.equals(other.nom)) {
            return false;
        }
        if (pass == null) {
            if (other.pass != null) {
                return false;
            }
        } else if (!pass.equals(other.pass)) {
            return false;
        }
        if (prenom == null) {
            if (other.prenom != null) {
                return false;
            }
        } else if (!prenom.equals(other.prenom)) {
            return false;
        }
        if (roleEmploye != other.roleEmploye) {
            return false;
        }
        return true;
    }
}
